package com.xpsoft.oa.dao.produce.impl;


import java.util.List;

import org.hibernate.Query;

import com.xpsoft.core.dao.impl.BaseDaoImpl;
import com.xpsoft.oa.dao.produce.ProjectRepertoryDao;
import com.xpsoft.oa.model.produce.ProjectRepertory;

public class ProjectRepertoryDaoImpl extends BaseDaoImpl<ProjectRepertory> implements ProjectRepertoryDao{

	public ProjectRepertoryDaoImpl() {
		super(ProjectRepertory.class);
	}

	@Override
	public ProjectRepertory getRepertory(Long proId, Long materialId) {
		// TODO Auto-generated method stub
		String hql = "from ProjectRepertory where project.id=:proId and material.id=:materialId ";
		Query query = getSession().createQuery(hql).setParameter("proId", proId).setParameter("materialId", materialId);
		ProjectRepertory projectRepertory = null;
		List<ProjectRepertory> list = query.list();
		if(list!=null&&list.size()>0){
			projectRepertory = list.get(0);
		}
		return projectRepertory;
	}

}